package org.example.word;

import lombok.extern.slf4j.Slf4j;
import org.example.word.parser.AdaptApplicationFormParser;
import org.example.word.parser.TestApplicationFormParser;
import org.example.word.parser.TestProgressFormParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.InputStream;

@Service
@Slf4j
public class WordTableParserService {
    
    @Autowired
    private AdaptApplicationFormParser adaptApplicationFormParser;
    
    @Autowired
    private TestApplicationFormParser testApplicationFormParser;
    
    @Autowired
    private TestProgressFormParser testProgressFormParser;

    public Object parse(InputStream in, ParseType type) throws Exception {
        return switch (type) {
            case ADAPT_APPLICATION -> adaptApplicationFormParser.parse(in);
            case TEST_APPLICATION -> testApplicationFormParser.parse(in);
            case TEST_PROGRESS -> testProgressFormParser.parse(in);
        };
    }

    public enum ParseType {
        ADAPT_APPLICATION,
        TEST_APPLICATION,
        TEST_PROGRESS;
    }
}